<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/fn"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="display" uri="http://displaytag.sf.net"%>

<%-- Creates a table header. Parameters are :
    - code : optional, the code for the header label. Exclusive with the "titleLabel" param.
    - label : optional, the header label. Exclusive with the "titleCode" param.
    - class : optional, the header classes.
    - initTableJs : optional, whether to initialize the column headers for the whole table by
              means of javascript. Must be called only once per table, for the last column.
--%>

<%-- Getting the labels --%>
<c:choose>
  <c:when test="${empty param.label}">
    <spring:theme var="titleLabel" code="${param.code}" />
    <spring:theme var="titleLongLabel" code="${param.code}" />
  </c:when>
  <c:otherwise>
    <c:set var="titleLabel" value="${param.label}" />
  </c:otherwise>
</c:choose>

<%-- Building the header --%>
<th class="${param.class} ${empty titleLongLabel ? '' : 'titleWithDetails'}">
  ${titleLabel}
  <c:if test="${not empty titleLongLabel}">
    <span class="longTitle" style="display:none">${titleLongLabel}</span>
  </c:if>
</th>

<%-- Adding the Javascript initialization, if required --%>
<c:if test="${param.initTableJs == 'true'}">
  <script type="text/javascript">$(document).ready(function(){
    initInfoBoxesOnTableHeader();});</script>
</c:if>